//
//  ReportTableViewCell.m
//  兼职页面
//
//  Created by kuiyuan liang on 2021/5/25.
//

#import "ReportTableViewCell.h"
#import "CommonUtil.h"

@interface ReportTableViewCell()


@property (strong, nonatomic) UILabel * nameLabel;
@property (strong, nonatomic) UIImageView * iconImageView;
@property (strong, nonatomic) UITextField * inputField;

@end

@implementation ReportTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self.contentView addSubview:self.nameLabel];
        [self.contentView addSubview:self.iconImageView];
        [self.contentView addSubview:self.inputField];
    }
    return self;
}


-(void)layoutSubviews{
    [super layoutSubviews];
    self.nameLabel.centerY = self.height/2;
    self.iconImageView.centerY = self.height/2;
    self.iconImageView.right = self.width - AD(15);
    self.inputField.height = self.height;
}


-(void)refreshWithTitle:(NSString *)title selectTitles:(NSArray *)selectTitles{
    
    self.nameLabel.text = title;
    
    if ([selectTitles containsObject:title]) {
        self.iconImageView.image = [UIImage imageNamed:@"icon_report_select"];
    }else{
        self.iconImageView.image = [UIImage imageNamed:@"icon_report"];
    }
    if ([title isEqualToString:@"其他原因"]) {
        self.iconImageView.hidden = YES;
        self.inputField.hidden = false;
    }else{
        self.iconImageView.hidden = false;
        self.inputField.hidden = YES;
    }

}



-(UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(AD(15), 0, AD(250), AD(25))];
        _nameLabel.font = [UIFont boldSystemFontOfSize:AD(18)];
        _nameLabel.textColor = [UIColor blackColor];
    }
    return _nameLabel;
}

-(UIImageView *)iconImageView{
    if (!_iconImageView) {
        _iconImageView = [[UIImageView alloc] init];
        _iconImageView.frame = CGRectMake(0, 0, AD(20), AD(20));
    }
    return _iconImageView;
}

-(UITextField *)inputField{
    if (!_inputField) {
        _inputField = [[UITextField alloc] initWithFrame:CGRectMake(AD(100), 0, AD(170), 0)];
        _inputField.font = [UIFont systemFontOfSize:AD(14)];
        _inputField.textColor = [UIColor blackColor];
    }
    return _inputField;
}

@end
